package com.geek.netty.demo;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * @program netty-server
 * @description: handler
 * @author: chanzhugang
 * @create: 2021/08/16 15:04
 */
public class RequestHandler extends Thread {

    private Socket socket;

    public RequestHandler(Socket socket) {
        this.socket = socket;
    }

    /**
     * 直接发送字符串
     */
    @Override
    public void run() {
        try (PrintWriter writer = new PrintWriter(socket.getOutputStream())) {
            writer.println("hello nio");
            writer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}